<?php
/**
 * Created by PhpStorm.
 * User: ADMIN
 * Date: 2021/5/18
 * Time: 17:48
 */
namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\ChangeCategory;

/**
 * Class System
 * @package app\api\controller
 */
class System extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 公共配置
     */
    public function config()
    {
        $config = config('site');
        $data['config']['applets_appid'] = $config['applets_appid'];
        $data['config']['applets_appsecret'] = $config['applets_appsecret'];
        $data['config']['mchId'] = $config['mchId'];
        $data['config']['mchkey'] = $config['mchkey'];
        $data['config']['business_information_key'] = $config['business_information_key'];
        $data['config']['precise_information_key'] = $config['precise_information_key'];
        $data['config']['search_consume_money'] = $config['search_consume_money'];
        if(!strstr($config['applets_logo'], request()->domain()))
        {
            $data['config']['applets_logo'] = request()->domain().$config['applets_logo'];
        }
        else
        {
            $data['config']['applets_logo'] = $config['applets_logo'];
        }
        $data['config']['banner'] = $config['banner'];
        if($data['config']['banner'])
        {
            foreach ($data['config']['banner'] as &$v)
            {
                if(!strstr($v, request()->domain()))
                {
                    $v = request()->domain().$v;
                }
            }
            unset($v);
        }

        // 变更类别
        $changeCategoryRes = ChangeCategory::getAll();
        $data['changeCategoryList'] = $changeCategoryRes['list'];

        $this->success('查询成功', $data);
    }
}